Repository navigation
feat(contract): contract form, order contract follows its order, Change on activated contracts (#2804) - #2813
Merged
objectstack-fleet[bot] merged 6 commits intoNov 26, 2026
Conversation
…ge on activated contracts (#2804) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
…s and Change (#2804) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
…kfill waits for summary-nulls (#2804) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
…tract-form-change
… actions (#2804) The end-date shrink rule is replaced by the Change lock, so the two hooks-runtime-service cases now pin RECORD_LOCKED 409 in both directions. The new hook is registered with runtime-coverage, and README / STATUS state 56 actions and 636 fields as `pnpm validate` prints. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…tract-form-change
Contributor
Author
|
repo:hotcrm#1 · huangyiirene · session_01J8VVAk8tegvAi1ECkgCFfc ACCEPT · 2026-11-26T11:01ZHead-sha: 维护者速读
席位核对
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Irene · project thread
Fixes #2804
Clause-②: no
Metadata-protocol: none
Metadata-impact: maintainer — a hook changed (new contract form and Change hook on crm_contract; the end-date-only lock in contract_validation is replaced) and a validation tightened (a direct edit of Contract Value, End Date or Payment Terms on an activated contract, through the form or the API, is now refused)
维护者速读
What changes
Contract form.
crm_contract.contract_form(select:order/framework/other, required, defaultframework) sits besidecontract_type, which is untouched. It is read-only once the contract leaves Draft, and always read-only on an order contract; no person can writeorder(only Draft Contract can).Order contract.
sales-order-draft-contract.flow.tsnow writescontract_form: 'order'and the newcrm_sales_orderlookup ("Source Order"; there was no source-order link before). The shared_contract-draft.tsgraph is untouched, so the quote-accepted draft stays a framework contract. The value is the order'stotal_price(the tax-inclusive total). The new summaryorder_amount(sum of the contract's orders'total_price) drives it: while the contract is Draft, a recompute oforder_amountsetscontract_value, andcontract_valueis read-only on the form. The first NULL-to-value computation, frommigrate summary-nulls, does not correct a value. The formulaorder_amount_differsshows Differs from the Order Amount when they part.Change. Two declarative record-header actions,
change_contract(framework/other) andchange_order_contract(order), shown only on an activated contract to someone who can edit it. Both requirechange_reasonandchange_amendment(a file). The framework action offers New Contract Value; the order action offers only Update from Order. Both offer optional New End Date and New Payment Terms. The new hookcontract_form_and_changeapplies the staged values, recomputescontract_term_monthsfor a new end date, clears the staging fields and leaves status Activated. It creates no change order, does not touch the order and does not re-plan payments.trackHistoryis now oncontract_value,start_date,end_date,payment_terms,change_reasonandchange_amendment.Locks.
readonlyWhenmakescontract_value,end_dateandpayment_termsread-only on an activated contract. The hook refuses a person's direct write withRECORD_LOCKED409, naming the field (reasons: contract_value / end_date / payment_terms / form). The old end-date-shrinkRECORD_LOCKEDincontract_validationis removed because the new rule covers it. A Change may now move the end date earlier, by design.Backfill. A contract with no form gets one on its next save: one drafted by Draft Contract and named by an order is an order contract (and gets that order as its Source Order), one with no value is Other, the rest are framework. Values are never changed.
scripts/backfill-contract-form.ts(report by default,--applyto write) gives every contract its form at once, then prints the order contracts whose value differs from their order amount. It waits forobjectstack migrate summary-nulls --apply --yesand exits non-zero while any order amount is still uncounted.Text. Labels, help, refusals and action text in en / zh-CN / es-ES / ja-JP. The Contracts manual in three locales, and the in-app help for contracts and orders, in two.
PM assumptions:
readonlyWhenon the form plus the hook, which writes the staged values. The user outcome matches the ruling.total_price). Confirmed.Tests
Run on head
45291a20. The logs are in the folded blocks below.test/contract-form-change.test.ts(new, 18 tests) covers:VALIDATION_ERROR400 for a missing reason or amendment, and the hook answersVALIDATION_FAILED400 (not_activated,order_value, missing amendment);sys_activity;trackHistory;test/backfill-contract-form.test.ts(new) covers the script against a stubbed REST server: report, apply, difference list, and the summary-nulls wait.Updated:
refusal-envelope(catalogue count 101→108);refusal-labels(new labels);sales-order-draft-contract(the order draft writes the quote keys pluscontract_formandcrm_sales_order).Also updated, because the change moved them:
hooks-runtime-service: the two end-date cases now pinRECORD_LOCKED409 in both directions;runtime-coverage: lists the new runtime file;docs/STATUS.md: 56 actions and 636 fields, aspnpm validateprints.Local runs:
pnpm validate,pnpm typecheck,pnpm lint(--strict) andpnpm hygiene: each exit 0.check-docs-locale-parity --base origin/main: exit 0.docs-*andi18n-*): 73 passed and 1 failed, 1561 tests passed. The one failure was runtime-coverage; it was fixed and re-run.45291a20: 5/5 files, 166/166 tests.vitest runwas started locally and stopped after about 30 minutes, unfinished. The part that ran surfaced the three files fixed above. The full suite is CI's run.Targeted run, 74 files
Final head 45291a2, five affected files
Acceptance notes
src/sales/views/contract.view.ts(adds Contract Form to the form),scripts/backfill-contract-form.ts, README / README.zh-CN /docs/STATUS.md(counts) and thehooks-runtime-service/runtime-coveragetests are outside the claim's file surface. The view and the script are needed by the ruling: without the view nobody sees the form value, and the script produces the backfill with its difference list. The counts and the two tests moved because of this change.requiredWhencannot sit on anotNullcolumn (ADR-0113).order_amountsums every order linked to the contract. A second order linked to an order contract would add into its Order Amount.5f778a99and will be merged again if Rename 回款节点 to 回款计划 everywhere it is shown (display names only) #2805 lands first.src/o2c/extensions/contract-account.extension.ts(Invoices and payments run in parallel: unlink them, show Unpaid and Uninvoiced instead of Receivable Balance, measure overdue on the payment plan, and generate a plan step when an order is confirmed #2806) is untouched.Verification
Measured on a copy of main's database, upgraded with the branch server on port 4012 and driven with headless Chrome.
backfill-contract-form.ts: the report, then--apply, gives Formed 6/6 (framework 4, order 2). Aftermigrate summary-nulls, the order amounts are counted.PATCH {payment_terms}is refused with 409RECORD_LOCKED: "An activated contract's Payment Terms change only through Change, with a reason and the signed amendment."contract_value220000→250000, the reason and the amendment, with actor Dev Admin.Two-minute check:
pnpm exec vitest run test/contract-form-change.test.ts, expected 18 passed. Or, in the app, open an activated contract and click Change: Reason and Signed Amendment are required, and Contract Value is not editable on the form.Read first, by risk:
src/sales/objects/contract.hook.ts: thecontract_form_and_changeupdate branch, especially the draft-follow guard (isSystem, not backfilled, previousorder_amounta number) and the Change apply block.src/sales/objects/contract.object.ts: thereadonlyWhenexpressions andorder_amount_differs.scripts/backfill-contract-form.ts: the--applyloop and the summary-nulls exit.🤖 Generated with Claude Code
https://claude.ai/code/session_01J8VVAk8tegvAi1ECkgCFfc